﻿using System.Collections.Generic;
using System.Linq;
using SQLPXBase.Factory.Keys;

namespace ExampleApplication.Models.Base
{
    internal class ModelCollection<T>:List<T>
        where T:BaseModel
    {
        public ModelCollection() { }

        #region Contains By ID e Get BY ID

        public bool ContainsById(PrimaryKey id)
        {
            return this.Any(t => id == t.Id);
        }

        public T GetById(PrimaryKey id)
        {
            return this.FirstOrDefault(t => id == t.Id);
        }

        #endregion
    }
}
